import java.util.logging.Logger

class CommandHandler(private val cache: Cache) {
    private val logger: Logger = Logger.getLogger(CommandHandler::javaClass.name)

    fun handle(command: String):String{
        val syntax = command.split(" ")
        var handleResult=""

        if(command.contains("set")){
            val commandKey = syntax[1]
            val commandValue = syntax[2]

            logger.info("handle set")
            cache.set(commandKey,commandValue)
        }

        if(command.contains("get")){
            val commandKey = syntax[1]
            val value = cache.get(commandKey)
            handleResult = value.toString()
        }

        return handleResult
    }


}